import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/* eslint-disable no-self-compare */
//行动态取数
import { CpasIcon, DevGrid } from "~/public/cpas-ui";
import AntTabs from "~/public/cpas-ui/components-ui/ant-components/AntTab";
import { Button, Card, Input, Modal, Radio, Select, message } from "antd";
import { LoadPanel, Scrolling, Sorting } from "devextreme-react/data-grid";
import React from "react";
import { SearchOutlined } from "@ant-design/icons";
// import { guid } from "../../../../tools/Tools";
import { createCellPos, formatDateField, formatNumberField, } from "../../../ExcelGrid/Tools";
import { getReportData, getDevTableData, getCorpData, getReportMenu, } from "../../classes/HandSonGridToolService/getDataSourceService";
import RowFilterFun from "./RowFilterFun";
import { getYears } from "../../../../tools/Tools";
import { dbname } from "../../classes/HandSonGridToolService/pubDbname";
import { msgError } from "./msg";
import { SelectBox } from "devextreme-react";
import { consts } from "../../../../tools/consts";
export default class RowData extends React.Component {
    newColumn1; // 用于更新dev表的新表头
    newColumn2;
    newListData1;
    newListData2;
    tabName;
    year1;
    year2;
    filterObjArrs;
    newFilterArrs;
    inpRef;
    inpRef2;
    inpOrderRef;
    digaoSelctOne;
    devGridRef2;
    sortRef;
    filterRef;
    excludeRef;
    excludeRef2;
    cpasType; // cpas表的表头类型
    devType; // dev 表的表头类型
    // types: any; // dev表头类型
    //childRef: any;
    colDatas;
    colOrders;
    topParam;
    newProps;
    delArrs;
    reportGridRef; //企业报表数据引用
    constructor(props) {
        super(props);
        console.log("888---rowData--props", props);
        this.inpRef = React.createRef();
        this.inpRef2 = React.createRef();
        this.devGridRef2 = React.createRef();
        this.sortRef = React.createRef(); // 排序面板
        this.filterRef = React.createRef(); // 排序面板
        this.excludeRef = React.createRef(); // 排序区域
        this.excludeRef2 = React.createRef(); // 筛选区域
        //this.childRef = React.createRef();
        this.inpOrderRef = React.createRef();
        this.reportGridRef = React.createRef();
        this.createRelation = this.createRelation.bind(this);
        this.AccountTabsClick = this.AccountTabsClick.bind(this);
        this.devTableDbck = this.devTableDbck.bind(this);
        this.changeInp1 = this.changeInp1.bind(this);
        this.changeInp2 = this.changeInp2.bind(this);
        this.selDataSource1 = this.selDataSource1.bind(this);
        this.selDataSource2 = this.selDataSource2.bind(this);
        this.ckRowData = this.ckRowData.bind(this);
        this.filterItem = this.filterItem.bind(this);
        this.isOrders = this.isOrders.bind(this);
        //this.singleSort = this.singleSort.bind(this);
        this.DigaoItem = this.DigaoItem.bind(this);
        this.refresh1 = this.refresh1.bind(this);
        this.refresh2 = this.refresh2.bind(this);
        this.filterCancel = this.filterCancel.bind(this);
        this.singleSort2 = this.singleSort2.bind(this);
        this.setConfirmSort = this.setConfirmSort.bind(this);
        this.getSortVal = this.getSortVal.bind(this);
        this.clearSort = this.clearSort.bind(this);
        this.changeItem = this.changeItem.bind(this);
        this.changeVal = this.changeVal.bind(this);
        this.changeInpVal = this.changeInpVal.bind(this);
        this.handleUndoDelete = this.handleUndoDelete.bind(this);
        this.handleDelete = this.handleDelete.bind(this);
        this.cancelRelation = this.cancelRelation.bind(this); //取消对应关系
        this.getOrderStr = this.getOrderStr.bind(this); //排序字符串
        this.genFilterComponents = this.genFilterComponents.bind(this); //过滤条件组件
        this.updateTopValue = this.updateTopValue.bind(this); //过滤条件组件
        this.filterObjArrs = [];
        this.newFilterArrs = [];
        this.state = {
            proName: "",
            valParam1: "",
            valParam2: "",
            defaultVal: "",
            saveArr: [],
            rowVal3: "",
            cpasHeader: JSON.parse(JSON.stringify(this.props.cpasData.header)),
            activeIndex3: 0,
            dataSource1: "",
            dataSource2: "",
            columnsData: this.props.columnsData || [],
            listData: [],
            cpasData: [],
            oneHeaders: [],
            getTraslates: [],
            defLabel: "",
            isFilter: false,
            isOrder: false,
            isShow: false,
            text1: "且",
            fieldList: this.props.columnsData,
            condionList: [],
            leftKuohao: "",
            rightKuohao: "",
            filterVal: "",
            filterField: "",
            condions: "",
            getWheres: {},
            getTops: {},
            getComDataSoureSelect: [],
            getDiGaoSourceSelect: [],
            getNumberSourceSelect: [],
            dataList: "",
            singleValueGroup: [],
            singleValueStr: [],
            getYearsVal: [],
            components: [],
            deletedComponents: [],
            filterObjs: {},
            newFilters: [],
            // curYear: new Date().getFullYear().toString(), // 年度下拉默认本年
            curYear: "2017",
            activeKeys: consts.WpTabKey,
            digaoColumn: [],
            digaoList: [],
            // selectedValue: this.props.getDiGaoSourceSelect[0].ReportItem,
            selectedValue: "",
            selectYear: "2019",
            value1: "",
            qsyDefaultVal: "",
            qsyDefaultVal2: "",
            getrowSrc2: "",
            getrowSrc2event: "",
            getYearVal: "",
            types: "",
            sortList: [],
            sortVal: "",
            chgItem: "",
            chgItemVal: "",
            orderOpts: [
                {
                    label: "前几项",
                    value: "prevItem",
                },
                {
                    label: "后几项",
                    value: "nextItem",
                },
            ],
            yearInp: consts.ThisYear,
            text2: "0",
        };
    }
    // *********************** 行动态弹窗中最上面的数据关系渲染以及存储 start
    createCpasHeader(isSetState) {
        // let cpasHeader = this.state.cpasHeader;
        let cpasHeader = JSON.parse(JSON.stringify(this.props.cpasData.header));
        cpasHeader.map((item, index) => {
            if (index === 0 || index === cpasHeader.length - 1) {
                return item;
            }
            else {
                item.dataListMap = "";
                if (this.state.saveArr) {
                    this.state.saveArr.map((ite) => {
                        return ite.sourceMap === item.label
                            ? (item.dataListMap = ite.dataListMap)
                            : "尚未对应";
                    });
                }
                return item;
            }
        });
        /*  let data0 = this.props.cpasData.data[0];
     
        cpasHeader.forEach((element: any, i: any) => {
          if (i === 0 || i === cpasHeader.length - 1) {
            return element;
          } else {
            data0.map((da, idx) => {
              if (i > 0) {
                if (i === idx) {
                  element.label = da;
                }
              }
              return element;
            });
    
            element.dataListMap = "";
            if (this.state.saveArr) {
              this.state.saveArr.map((ite: any) => {
                return ite.sourceMap === element.label
                  ? (element.dataListMap = ite.dataListMap)
                  : "尚未对应";
              });
            }
          }
        }); */
        if (isSetState) {
            this.setState({
                cpasHeader: cpasHeader,
            });
        }
        console.log("888--createCpasHeader", cpasHeader);
        return cpasHeader;
    }
    // **************  行动态弹窗中最上面的数据关系渲染以及存储 end
    // cpas dev 关系建立：
    createRelation(sourceMap, dataListMap, cpasIndex, devIndex) {
        let relationArr = {};
        relationArr = {
            sourceMap: sourceMap,
            dataListMap: dataListMap,
            cpasIndex: cpasIndex,
            devIndex: devIndex,
        };
        return relationArr;
    }
    // tab 页签名称
    async AccountTabsClick(activeKey) {
        try {
            this.tabName = activeKey;
            this.setState({
                activeKeys: activeKey,
            });
            this.props.activeTab(activeKey);
            if (activeKey === consts.ReportTabKey) {
                await this.EnterpriseBaseData(); // 企业基础数据-取数源
            }
            if (activeKey === consts.WpTabKey) {
                await this.getDiGaoOption(); // 底稿结构化数据 - 底稿名称
            }
        }
        catch (err) {
            console.error(err);
        }
    }
    // 上面动态弹窗 数据点击交互事件,
    ckRowData(e, index, item) {
        this.cpasType = item.config.type;
        console.log("888---ckRowData", item.config.type, this.cpasType);
        this.setState({
            rowVal3: item.label,
            activeIndex3: index,
        });
    }
    //取消对应
    cancelRelation(e, index, item) {
        e.stopPropagation(); //阻止事件冒泡
        //删除数组中对应元素
        let curIndex = this.state.saveArr.findIndex((findItem) => findItem.dataListMap == item.dataListMap);
        if (curIndex > -1) {
            this.state.saveArr.splice(curIndex, 1);
        }
        this.createCpasHeader(true);
        // 把建立的两表关系传给父组件
        this.props.getTraslates(this.state.saveArr);
    }
    // 点击列，拿到当前列值,并创建关联关系进行保存
    async devTableDbck(e) {
        console.log("888--edevTableDbck", e);
        let result = await getYears(consts.ThisYear);
        this.interfaceDiGaoHeader(this.state.dataSource2
            ? this.state.dataSource2
            : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", true, this.topParam);
        this.devType = e.column.dataType;
        if (this.devType) {
            //没有选中加提示
            if (!this.cpasType) {
                return message.open({
                    type: "warning",
                    content: "请在上面部分选择列名后才能继续。",
                    className: "custom-class",
                    style: {
                        marginTop: "20vh",
                    },
                });
            }
            if ((this.devType === "number" && this.cpasType === "numeric") ||
                (this.devType === "string" && this.cpasType === "text")) {
                //查找是否有对应的,存在的删除 add by csb
                let findIndex = this.state.saveArr.findIndex((item) => item.sourceMap === this.state.rowVal3);
                if (findIndex > -1) {
                    this.state.saveArr.splice(findIndex, 1);
                }
                // 建立关系
                let result = this.createRelation(this.state.rowVal3, e.column.caption, this.state.activeIndex3, e.columnIndex); //relationArr
                this.state.saveArr.push(result); // 把每次点击建立的关系保存到数组中
                this.createCpasHeader(true);
                // 把建立的两表关系传给父组件
                this.props.getTraslates(this.state.saveArr);
            }
            else {
                message.open({
                    type: "warning",
                    content: "数据类型不匹配,不可建立关系",
                    className: "custom-class",
                    style: {
                        marginTop: "20vh",
                    },
                });
            }
        }
    }
    //******** 检索条件接口调用 start */
    //企业基础数据 -- 取数源
    async EnterpriseBaseData() {
        try {
            let dataSource1 = this.state.dataSource1;
            let qsyDefaultVal = this.state.qsyDefaultVal;
            let data = await getCorpData();
            // 需要转化一下格式
            const transferData = data.map((item) => {
                return { label: item.dataSrcName, value: item.dmName };
            });
            if (!dataSource1 || !qsyDefaultVal) {
                dataSource1 = data[0].dmName; // 这两个值一样
                qsyDefaultVal = transferData[0].value; // 这两个值一样
            }
            this.setState({
                getComDataSoureSelect: transferData,
                qsyDefaultVal: qsyDefaultVal,
                dataSource1: dataSource1, //英文名
            });
            this.props.getrowSrc2event(transferData[0]);
            let result = await getYears(this.state.yearInp || consts.ThisYear);
            this.interfaceQiYeListData(
            /* this.state.dataSource1 ? this.state.dataSource1 :transferData[0].value, */
            qsyDefaultVal, result.toString(), dbname, [], "", "", false, 0);
            this.interfaceQiYeHeader(
            /*  this.state.dataSource1 ? this.state.dataSource1 : transferData[0].value */
            qsyDefaultVal, this.state.yearInp || result.toString(), dbname, [], "", "", true, 0);
        }
        catch (err) {
            console.error(err);
        }
    }
    // 底稿结构化数据 -- 底稿名称列表 接口拿数据
    async getDiGaoOption(drData) {
        const newDrData = (drData || {});
        //报表项目,以公式定义的优先
        let itemName = newDrData.displayReportItem || this.props.itemName;
        const data = await getReportMenu();
        const uniqueData = data
            .map((item) => item.ReportItem)
            .filter((value, index, arr) => arr.indexOf(value) === index)
            .map((reportItem) => ({ ReportItem: reportItem }));
        // 转化数据格式，展示下拉框
        if (data.length > 0) {
            //老公式没有定义一个 displayReportItem属性导致的
            if (!itemName && newDrData.dataList) {
                //如果没itemName值,但有公式名称api时
                const itemFilters = data.filter((item) => newDrData.dataList.startsWith(item.ReportItemCode));
                if (itemFilters.length > 0) {
                    itemName = itemFilters[0].ReportItem; //取报表项目名称
                }
            }
            const transferData = uniqueData.map((item) => {
                return { label: item.ReportItem, value: item.ReportItem };
            });
            this.setState({
                getDiGaoSourceSelect: transferData,
                selectedValue: transferData[0].value,
            });
            this.digaoSelctOne = transferData[0].value;
            //如果存在传入的项目名称,底稿名称下拉框要默认对应上去
            if (transferData.some((item) => item.label === itemName)) {
                this.digaoSelctOne = itemName;
            }
            await this.DigaoItem(this.digaoSelctOne, newDrData); // 底稿名称默认有值的时候，取数源下拉数据也要默认有的，但是不选中
            // 此代码有用，后期再测试功能 当itemName存在时，底稿名称下拉框要默认对应上去
            /* if ((this.tabName = consts.WpTabKey && this.props.itemName)) {
              // 左边树节点点击拿到的报表项目名称和底稿名称对应在上去。就默认出来
              transferData.filter((item) => {
                if (item.label === this.props.itemName) {
                  this.setState({
                    selectedValue: this.props.itemName,
                  });
                } else {
                  this.setState({
                    selectedValue: transferData[0].value,
                  });
                }
              });
            } else {
              this.setState({
                selectedValue: transferData[0].value,
              });
            } */
        }
    }
    //******** 检索条件接口调用 end */
    // 企业基础数据--取数源 下拉框 取值
    async selDataSource1(val, item) {
        console.log("888--企业基础数据selDataSource1", val, this.state.dataSource1);
        try {
            this.props.getrowSrc2event(item);
            this.setState({
                dataSource1: val,
                defaultVal: item.label,
                defLabel: item.value,
                qsyDefaultVal: val, // 默认值改变
            });
            let result = await getYears(consts.ThisYear);
            this.interfaceQiYeListData(val, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", false, 0);
            this.interfaceQiYeHeader(val, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", true, 0);
        }
        catch (err) {
            console.error(err);
        }
    }
    // 底稿结构化---取数源触发事件
    async selDataSource2(val, item) {
        try {
            this.props.getrowSrc2event(item);
            this.setState({
                dataSource2: val,
                defaultVal: item.label,
                defLabel: item.value, // 英文参数
            });
            let result = await getYears(consts.ThisYear);
            await this.interfaceDiGaoHeader(val, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", true, this.topParam);
            await this.interfaceDiGaoListData(val, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", false, this.topParam);
        }
        catch (err) {
            console.error(err);
        }
    }
    // 底稿结构化数据 - 底稿名称 触发事件，取数源列表实现数据切换
    /**
     * 获取底稿结构化子表
     * @param itemName 报表项目
     */
    async DigaoItem(itemName, drData) {
        const newDrData = (drData || {});
        try {
            this.setState({ selectedValue: itemName });
            let data = await getReportData(itemName);
            if (data.length === 0)
                return msgError("报表项目找不到子项:" + itemName);
            let curDmName = ""; //当前的api接口
            const items = data.map((item) => {
                //借用一下,如果找到api名称,赋值
                if (item.dmName === newDrData.dataList) {
                    curDmName = item.dmName;
                }
                return { label: item.dataSrcName, value: item.dmName };
            });
            curDmName = curDmName || items[0].value;
            if (items) {
                this.setState({
                    getNumberSourceSelect: items,
                    qsyDefaultVal2: curDmName,
                    dataSource2: curDmName,
                });
            }
            //找到当前项目传给父组件,干啥用呢?
            let curItemList = items.filter((item) => item.value === curDmName);
            this.props.getrowSrc2event(curItemList.length > 0 ? curItemList[0] : items[0]);
            // 底稿结构化数据  默认打开页面的时候 接口自执行
            const result = await getYears(newDrData.dataId || this.state.yearInp || consts.ThisYear);
            if (result) {
                await this.interfaceDiGaoHeader(curDmName, result.toString(), dbname, [], newDrData.where || "", newDrData.order || "", true, 0);
                await this.interfaceDiGaoListData(curDmName, result.toString(), dbname, [], newDrData.where || "", newDrData.order || "", false, this.topParam);
            }
        }
        catch (err) {
            console.error(err);
        }
    }
    //年度-触发年度下拉框取出值
    // 新的 UI库组件
    async selYear1(val) {
        try {
            const result = await getYears(val.value);
            this.props.getYearVal(val.value); // 属性传值
            this.setState({
                valParam1: result.toString(),
                yearInp: val.value,
            });
            this.interfaceQiYeListData(this.state.dataSource1
                ? this.state.dataSource1
                : this.state.qsyDefaultVal, result.toString(), dbname, [], "", "", false, 0);
            this.interfaceQiYeHeader(this.state.dataSource1
                ? this.state.dataSource1
                : this.state.qsyDefaultVal, result.toString(), dbname, [], "", "", true, 0);
        }
        catch (err) {
            console.error(err);
        }
    }
    async selYear2(val) {
        try {
            const result = await getYears(val.value);
            this.props.getYearVal(val.value);
            this.setState({
                valParam2: result.toString(),
                yearInp: val.value,
            });
            await this.interfaceDiGaoHeader(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, result.toString(), dbname, [], "", "", true, 0);
            await this.interfaceDiGaoListData(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, result.toString(), dbname, [], "", "", false, this.topParam);
        }
        catch (err) {
            console.error(err);
        }
    }
    // // 封装的模糊检索方法
    // fuzzyQuery(list, keyWord) {
    //   var arr = [];
    //   for (var i = 0; i < list.length; i++) {
    //     if (list[i].项目 && list[i].项目.indexOf(keyWord) >= 0) {
    //       arr.push(list[i]);
    //     }
    //     if (list[i].项目名称 && list[i].项目名称.indexOf(keyWord) >= 0) {
    //       arr.push(list[i]);
    //     }
    //   }
    //   return arr;
    // }
    // 封装的模糊检索方法 -- 2023.7.10 下午14:45 邵宏和我定的按‘主键’搜索
    fuzzyQuery(list, keyWord) {
        var arr = [];
        for (var i = 0; i < list.length; i++) {
            if (list[i].主键 && list[i].主键.indexOf(keyWord) >= 0) {
                arr.push(list[i]);
            }
        }
        return arr;
    }
    // 项目名称
    async changeInp1(e) {
        try {
            this.setState({
                proName: this.inpRef.current.input.value,
            });
            let result = getYears(consts.ThisYear);
            this.interfaceQiYeListData(this.state.dataSource1
                ? this.state.dataSource1
                : this.state.qsyDefaultVal, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", false, 0);
            this.interfaceQiYeHeader(this.state.dataSource1
                ? this.state.dataSource1
                : this.state.qsyDefaultVal, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", true, 0);
        }
        catch (err) {
            console.error(err);
        }
    }
    async changeInp2(e) {
        try {
            this.setState({
                proName: this.inpRef2.current.input.value,
            });
            let result = await getYears(consts.ThisYear);
            await this.interfaceDiGaoHeader(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", true, 0);
            await this.interfaceDiGaoListData(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", false, this.topParam);
        }
        catch (err) {
            console.error(err);
        }
    }
    async refresh1(yearTag) {
        // 刷新一遍接口
        //检索条件保留不变，去进行刷新
        try {
            let result = await getYears(yearTag || consts.ThisYear);
            this.interfaceQiYeListData(this.state.qsyDefaultVal, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", false, 0);
            this.interfaceQiYeHeader(this.state.qsyDefaultVal, this.state.valParam1 ? this.state.valParam1 : result.toString(), dbname, [], "", "", true, 0);
        }
        catch (err) {
            console.error(err);
        }
    }
    async refresh2(yearTag) {
        try {
            //检索条件保留不变，去进行刷新
            let result = await getYears(yearTag || consts.ThisYear);
            await this.interfaceDiGaoHeader(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", true, this.topParam);
            await this.interfaceDiGaoListData(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], this.props.conditonStr, this.getOrderStr(), false, this.topParam);
        }
        catch (err) {
            console.error(err);
        }
    }
    //底稿结构化 -- 筛选 显示/隐藏
    filterItem() {
        this.setState({
            isFilter: !this.state.isFilter,
        });
    }
    // 对象数组去重方法:根据提供的属性去重,勿删，
    arrDistinctByProp(arr, prop) {
        let obj = {};
        return arr.reduce((preValue, item) => {
            if (obj[item[prop]] ? "" : (obj[item[prop]] = true && preValue.push(item))) {
                return preValue;
            }
            else {
                return preValue;
            }
        }, []);
    }
    //底稿结构化 -- 筛选 --添加一行
    addRow = () => {
        this.newColumn2.map((its) => {
            this.setState({
                types: its.fieldType,
            });
            return its;
        });
        let id = Date.now();
        const newItem = {
            id: id,
            isNew: true,
            content: (_jsx(RowFilterFun
            // ref={this.childRef}
            , { 
                // ref={this.childRef}
                columnsData: this.newColumn2, onDelete: this.handleDelete, onValueChange: this.handleValueChange, keys: id })),
        };
        this.setState((prevState) => ({
            components: [...prevState.components, newItem],
        }));
    };
    //备用
    // handleDelete = (index) => {
    //   this.setState((prevState) => {
    //     const components = [...prevState.components];
    //     components.splice(index, 1);
    //     return { components };
    //   });
    //   let delNewdatas: any;
    //   delNewdatas = this.arrDistinctByProp(this.filterObjArrs, "filterField");
    //   delNewdatas.splice(index, 1);
    //   this.newFilterArrs = delNewdatas;
    //   this.filterObjArrs = delNewdatas;
    // };
    handleDelete = (itemId) => {
        this.setState((prevState) => {
            const components = [...prevState.components];
            const findIndex = components.findIndex((item) => item.id === itemId);
            const deletedComponent = components.splice(findIndex, 1); // Remove the component
            console.log("888---del", components);
            return { components, deletedComponents: [deletedComponent] };
        });
        /*  let delNewdatas: any;
        delNewdatas = this.arrDistinctByProp(this.filterObjArrs, "filterField");
        delNewdatas.splice(itemId, 1);
        this.newFilterArrs = delNewdatas;
        this.filterObjArrs = delNewdatas;
        */
        //改写 by csb 20230706
        this.filterObjArrs = this.filterObjArrs.filter((item) => item.keys !== itemId);
        this.newFilterArrs = this.filterObjArrs;
        // console.log("888--handleDelete", index);
    };
    handleUndoDelete = () => {
        this.setState((prevState) => {
            console.log("888--handleUndoDelete--prevState", prevState);
            const components = [...prevState.components];
            const deletedComponents = [...prevState.deletedComponents];
            const restoredComponent = deletedComponents.pop();
            components.push(...restoredComponent);
            console.log("888---huifu", components, restoredComponent, deletedComponents);
            return { components, deletedComponents };
        });
    };
    /**
     * 获取排序字符串
     * @returns
     */
    getOrderStr = () => {
        return this.state.singleValueGroup.join(",");
        /*  return this.state.singleValueGroup.length > 0
           ? this.state.singleValueGroup[this.state.singleValueGroup.length - 1]
           : ""; */
    };
    handleValueChange = (data, keys) => {
        //如果id存在的,先删除 add by csb
        let findIndex = this.filterObjArrs.findIndex((item) => item.keys === keys);
        if (findIndex > -1) {
            this.filterObjArrs.splice(findIndex, 1);
        }
        let newData = {
            keys: keys,
            data: data,
        };
        this.filterObjArrs.push(newData);
    };
    // 底稿结构化 -- 筛选--确定按钮
    filterComfirm = async () => {
        let list = this.filterObjArrs.map((item) => {
            return { ...item.data, id: item.keys };
        });
        list = list.sort((a, b) => a.id - b.id);
        //验证
        for (const i in list) {
            const oneFilter = list[i];
            const rowIndexStr = "第" + (Number(i) + 1) + "行,";
            if (!oneFilter.filterField) {
                return msgError(rowIndexStr + "[列字段名称]不能为空.");
            }
            if (!oneFilter.condions) {
                return msgError(rowIndexStr + "[条件]不能为空.");
            }
        }
        this.newFilterArrs = list;
        //确定时,把isNew设置为False,删除这个属性也行
        this.state.components.forEach((item) => (item.isNew = false));
        let str = "";
        let str0 = "", str1 = "";
        for (let n in list) {
            if (Number(n) === 0) {
                let fiterVal = "";
                if (list[0].condions === "like" || list[0].condions === "not like") {
                    fiterVal = `%${list[0].filterVal}%`;
                }
                else {
                    fiterVal = list[0].filterVal;
                }
                fiterVal = fiterVal.replaceAll("'", "''"); //替换掉'为两个
                if (list[0].type === "number") {
                    str0 = `${list[0].leftKuohao} [${list[0].filterField}] ${list[0].condions} ${fiterVal}   ${list[0].rightKuohao} `;
                }
                else {
                    str0 = `${list[0].leftKuohao} [${list[0].filterField}] ${list[0].condions} '${fiterVal}' ${list[0].rightKuohao} `;
                }
            }
            else if (Number(n) > 0) {
                let fiterVal = "";
                if (list[n].condions === "like" || list[n].condions === "not like") {
                    fiterVal = `%${list[n].filterVal}%`;
                }
                else {
                    fiterVal = list[n].filterVal;
                }
                fiterVal = fiterVal.replaceAll("'", "''"); //替换掉'为两个
                if (list[n].type === "number") {
                    str1 +=
                        `${list[n].text1 === "且" ? "and" : "or"} ` +
                            `${list[n].leftKuohao} [${list[n].filterField}] ` +
                            `${list[n].condions} ${fiterVal} ${list[n].rightKuohao} `;
                }
                else {
                    str1 +=
                        `${list[n].text1 === "且" ? "and" : "or"} ` +
                            `${list[n].leftKuohao} [${list[n].filterField}] ` +
                            `${list[n].condions} '${fiterVal}' ${list[n].rightKuohao} `;
                }
            }
        }
        str = str0 + str1; // 往接口传的参数 (期初数|未审数>11) or (类别<11)
        console.log("888---str", str);
        this.props.getConditions(str);
        this.props.getWheres(this.formulaCondion()); // 执行到父组件
        //关闭筛选下拉界面
        this.setState({
            isFilter: false,
        });
        /* 错误代码 mark by csb 异步的怎么能取到值呢?
         let year = "";
         let currentDataYear =  getYears(consts.ThisYear);
         currentDataYear.then((result) => {
           year = result.toString();
         }); */
        let year = await getYears(consts.ThisYear); //用这个能同步取到值
        await this.interfaceDiGaoHeader(this.state.dataSource2
            ? this.state.dataSource2
            : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : year, dbname, [], str, "", true, this.topParam);
        await this.interfaceDiGaoListData(this.state.dataSource2
            ? this.state.dataSource2
            : this.state.qsyDefaultVal2, this.state.valParam2 || year, dbname, [], str, this.getOrderStr(), //this.order,  this.state.singleValueGroup
        false, this.topParam);
    };
    filterCancel() {
        //关闭筛选下拉界面
        this.setState({
            isFilter: false,
        });
        // console.log("888--cancel", this.state.components);
        //取消时把新的删除,找出需要删除的keys
        let needDeleteKeys = this.state.components
            .filter((item) => item.isNew === true)
            .map((item) => item.id);
        //删除新加的组件
        this.setState({
            components: this.state.components.filter((item) => !needDeleteKeys.includes(item.id)),
        });
        //过滤条件也要删除
        this.filterObjArrs = this.filterObjArrs.filter((item) => !needDeleteKeys.includes(item.keys));
        this.setState((prevState) => {
            if (prevState.deletedComponents.length > 0) {
                this.handleUndoDelete();
            }
        });
    }
    // 底稿结构化 - 排序
    isOrders() {
        this.setState({
            // isOrder: !this.state.isOrder,
            isOrder: true,
        });
    }
    // 排序设置按钮事件
    async setConfirmSort() {
        try {
            this.setState({
                isOrder: false,
            });
            //  排序参数格式拼装 `[${str}]`
            let sortVals = `[${this.state.sortVal}] ` + (this.state.value1 || "asc");
            if (this.state.sortVal === "" && this.state.value1 === "") {
                sortVals = null;
            }
            console.log("888--sortVals", sortVals);
            let result = await getYears(consts.ThisYear);
            // 调接口，更新dev表数据
            await this.interfaceDiGaoHeader(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], "", "", true, this.topParam);
            await this.interfaceDiGaoListData(this.state.dataSource2
                ? this.state.dataSource2
                : this.state.qsyDefaultVal2, this.state.valParam2 ? this.state.valParam2 : result.toString(), dbname, [], this.props.conditonStr, sortVals, false, this.topParam);
            if (!this.state.singleValueGroup.includes(sortVals)) {
                this.state.singleValueGroup.push(sortVals);
            }
            // 把值通过下面方法传给父亲
            /*    this.formulaCondion();
            this.props.getWheres(this.formulaCondion()); // 执行到父组件 */
        }
        catch (err) {
            console.error(err);
        }
    }
    // 排序下拉框触发事件
    getSortVal(e) {
        this.setState({
            sortVal: e,
        });
    }
    // 排序的清空事件
    clearSort() {
        this.setState({
            value1: "",
            sortVal: "",
            chgItem: "",
            chgItemVal: "",
            text2: "0",
            singleValueGroup: [],
        });
        this.getSortVal("");
        this.topParam = "0";
    }
    // 排序单选按钮触发事件
    singleSort2(e) {
        this.setState({
            value1: e.target.value,
        });
    }
    // 前几项 / 后几项
    changeItem(e, item) {
        this.setState({
            chgItem: item.label,
            chgItemVal: item.value,
            text2: this.state.text2,
        });
        this.updateTopValue(item.value, this.state.text2);
    }
    /**
     * 更新top值
     * @param chgItemVal 类型
     * @param topValue top值
     */
    updateTopValue(chgItemVal, topValue) {
        let top = (chgItemVal === "nextItem" ? "-" : "") + topValue;
        this.props.getTop(top);
        this.topParam = top;
    }
    async changeVal(e) {
        this.createCpasHeader(true);
        try {
            this.setState({ text2: e.target.value });
            this.updateTopValue(this.state.chgItemVal, e.target.value);
            /* if (this.state.chgItem === "前几项") {
              top = e.target.value;
              this.topParam = top;
              this.props.getTop(top);
              console.log("888--前几项top", top);
            } else {
              top = "-" + e.target.value;
              this.topParam = top;
              this.props.getTop(top);
              console.log("888--后几项top", top);
            } */
        }
        catch (err) {
            console.error(err);
        }
    }
    changeInpVal(e) {
        console.log("8888--changeInpVal", e.target.value);
        let top = "0";
        if (this.state.chgItem === "前几项") {
            top = e.target.value;
            this.topParam = top;
            this.props.getTop(top);
        }
        else {
            top = "-" + e.target.value;
            this.topParam = top;
            this.props.getTop(top);
        }
    }
    // 组装公式-- 附加条件
    formulaCondion() {
        let strSingle = this.state.singleValueGroup;
        let strObj = {};
        let strArr = [];
        strSingle.map((item, i) => {
            if (item) {
                let newItem = item.split(" ");
                strObj = {
                    name: newItem[0],
                    sort: newItem[1],
                };
                strArr.unshift(strObj); // 向前插入，在后面去重的时候，用那个去重方法才能拿到正确的数据
                return item;
            }
        });
        console.log("888--formulaCondion--strArr", strArr);
        let obj = {
            newFilters: this.newFilterArrs,
            dataList: this.tabName === consts.ReportTabKey
                ? this.state.qsyDefaultVal
                : this.state.dataSource1,
            valParam: this.tabName === consts.ReportTabKey ? this.year1 : this.year2,
            singleValueStr: strArr,
            top: 0, // 前几项，后几项
        };
        console.log("888---obj", obj);
        return obj;
    }
    //界面回显示的初始化参数
    getInitParams = () => {
        this.newFilterArrs = [];
        this.topParam = ""; //排序
        return {
            components: [],
            saveArr: [],
            singleValueGroup: [],
            sortVal: "",
            value1: "",
            text2: "",
            chgItem: "",
            yearInp: consts.ThisYear, //年度
        };
    };
    /**
     *  filterObj = {
        leftKuohao: leftKuohao,
        rightKuohao: rightKuohao,
        text1: text1,
        filterField: filterField,
        condions: condions,
        filterVal: filterVal,
        type: fieldType,
      };
     * @param displayFilters
     */
    genFilterComponents(displayFilters) {
        //生成过滤的数组
        this.filterObjArrs = displayFilters.map((filterObj) => {
            return {
                keys: filterObj.id,
                data: filterObj,
            };
        });
        let components = displayFilters.map((filterObj) => {
            return {
                id: filterObj.id,
                isNew: false,
                content: (_jsx(RowFilterFun
                // ref={this.childRef}
                , { 
                    // ref={this.childRef}
                    defaultFilterObj: filterObj, filterObjArr: this.filterObjArrs, columnsData: this.newColumn2, onDelete: this.handleDelete, onValueChange: this.handleValueChange, keys: filterObj.id })),
            };
        });
        this.setState({ components });
    }
    /**
     * 是否是数字
     * @param str 字符串
     * @returns  boolean
     */
    isNumeric(str) {
        return !isNaN(str); /*  && !isNaN(parseFloat(str)) */
    }
    //在调用 render 方法之前调用，并且在初始挂载及后续更新时都会被调用
    // 关系回显方法
    async getReviewCpasMap(cpasHeader) {
        console.log("8888--关系回显this.newProps", this.newProps);
        ///////6.25
        if (this.newProps) {
            let rowDatas = this.newProps.cpasData.data;
            let rowF = this.newProps.coords.row;
            let rowFormula = rowDatas[rowF];
            let lastData = JSON.parse(rowFormula[rowFormula.length - 1]);
            let formula = lastData.formula;
            console.log("888--,formulformula", formula);
            if (formula) {
                let params = formula?.split("|||");
                let devCpasMap = params[1].slice(0, -1); // 两表关系映射
                let rowDevCpasMap = JSON.parse(devCpasMap); // 反转的两表关系
                //公式数据
                let drData = JSON.parse(params[0].substr(3)); // 附加条件 和表头 fields,where
                let updateValues = {};
                //映射关系
                updateValues.saveArr = rowDevCpasMap;
                //对应关系
                // this.setState({ saveArr: rowDevCpasMap }); //重新复制这个数组,有时候没有 add by csb
                this.props.getTraslates(rowDevCpasMap); //数据传给父
                if (drData.activeTab === consts.ReportTabKey) {
                    this.setState({
                        dataSource1: drData.dataList,
                        yearInp: drData.dataId + "",
                    });
                    this.refresh1();
                }
                else {
                    //底稿结构化数据
                    //年度字段
                    updateValues.yearInp = drData.dataId; //年度汉字标识,并不是2021这样的
                    //排序字段
                    if (drData.order) {
                        updateValues.singleValueGroup = drData.order?.split(","); //多个排序
                        if (updateValues.singleValueGroup.length > 0) {
                            const oneSortStr = updateValues.singleValueGroup[0] || ""; //目前只支持一个排序
                            const posRightZkh = oneSortStr.indexOf("]");
                            if (posRightZkh > -1) {
                                updateValues.sortVal = oneSortStr
                                    .substring(1, posRightZkh)
                                    .trim(); //排序字段
                                updateValues.value1 = oneSortStr
                                    .substring(posRightZkh + 1)
                                    .trim(); //排序类型asc/desc
                            }
                        }
                    }
                    //前几项
                    if (drData.top && this.isNumeric(drData.top)) {
                        let topInt = Number(drData.top); //数字值
                        updateValues.text2 = Math.abs(topInt); //前几项
                        updateValues.chgItem = topInt >= 0 ? "prevItem" : "nextItem"; //前几项
                        this.updateTopValue(updateValues.chgItem, updateValues.text2); //更新top值
                    }
                    else {
                        this.updateTopValue("prevItem", "0");
                    }
                    //where条件sql
                    if (drData.where) {
                        this.props.getConditions(drData.where);
                    }
                    //过滤条件的显示内容,可以生成 where
                    if (drData.displayFilters && Array.isArray(drData.displayFilters)) {
                        this.newFilterArrs = drData.displayFilters;
                        if (this.newColumn2) {
                            this.genFilterComponents(drData.displayFilters);
                        }
                    }
                    //底稿名称
                    await this.getDiGaoOption(drData);
                    // this.refresh2()
                }
                if (drData.activeTab) {
                    this.tabName = drData.activeTab;
                    updateValues.activeKeys = drData.activeTab;
                }
                this.setState(updateValues); //更新值
                console.log("888---行动态编辑公式", drData, rowDevCpasMap);
                //this.state.cpasHeader?.map((item: any) => {
                cpasHeader?.map((item) => {
                    rowDevCpasMap.map((ite) => {
                        if (ite.sourceMap === item.label) {
                            item.dataListMap = ite.dataListMap;
                        }
                        return item;
                    });
                    return item;
                });
                return { params0: drData, rowDevCpasMap };
            }
            else {
                console.log("888--没有关系");
                cpasHeader.forEach((item) => {
                    item.dataListMap = "";
                });
                this.setState({
                    dataSource1: this.state.qsyDefaultVal,
                    yearInp: consts.ThisYear,
                    saveArr: [],
                });
            }
        }
        this.setState({ cpasHeader: cpasHeader });
        this.forceUpdate();
    }
    // 企业基础数据
    async interfaceQiYeListData(tname, data_id, dbName, fields, where, order, queryMeta, top) {
        /* if (this.newListData1?.length > 20) {
           this.newListData1 = [];
           this.newColumn1 = [];
           // this.reportGridRef?.current?.instance.repaintRows();
           this.forceUpdate();
           return;
         } */
        try {
            let ab = await this.getDevListData_popRow(tname, data_id, dbName, fields, where, order, queryMeta, top);
            if (ab) {
                // formatNumberField(ab.columnDas);
                // this.newColumn1 = ab.columnDas;
                this.newListData1 = ab.devTableList;
                //模糊检索
                let filterListData = this.fuzzyQuery(this.newListData1, this.inpRef.current?.input?.value);
                this.newListData1 = filterListData;
                if (this.inpRef.current?.input?.value === "") {
                    this.newListData1 = ab.devTableList;
                }
                this.forceUpdate();
            }
            else {
                // this.newColumn1 = [];
                this.newListData1 = [];
                this.forceUpdate();
            }
        }
        catch (err) {
            console.error(err);
        }
    }
    // 企业基础数据 -- 拿表头数据类型
    async interfaceQiYeHeader(tname, data_id, dbName, fields, where, order, queryMeta, top) {
        let res = await this.getDevListData_dataTYpe(tname, data_id, dbName, fields, where, order, queryMeta, top);
        if (res && res.columnData) {
            formatNumberField(res.columnData);
            this.newColumn1 = res.columnData;
            this.forceUpdate();
        }
    }
    // 底稿结构化数据
    async interfaceDiGaoListData(tname, data_id, dbName, fields, where, order, queryMeta, top) {
        //TODO 由于后台存储过程采用临时表的方式, 这里加了延时防止并发的问题. 交互效果上这里要清空. 本质应该后台存储过程考虑并发问题
        this.newListData2 = [];
        this.forceUpdate();
        try {
            let ab = await this.getDevListData_popRow(tname, data_id, dbName, fields, where, order, queryMeta, top);
            if (ab) {
                formatDateField(ab.devTableList);
                this.newListData2 = ab.devTableList;
                //模糊检索
                let filterListData = this.fuzzyQuery(this.newListData2, this.inpRef2.current.input.value);
                this.newListData2 = filterListData;
                if (this.inpRef2.current.input.value === "") {
                    this.newListData2 = ab.devTableList;
                }
                this.forceUpdate();
            }
            else {
                // this.newColumn2 = [];
                this.newListData2 = [];
                this.forceUpdate();
            }
        }
        catch (err) {
            console.error(err);
        }
    }
    //底稿结构化表头数据类型
    async interfaceDiGaoHeader(tname, data_id, dbName, fields, where, order, queryMeta, top) {
        // 拿表头数据类型
        let res = await this.getDevListData_dataTYpe(tname, data_id, dbName, fields, where, order, queryMeta, top);
        if (res && res.columnData) {
            formatNumberField(res.columnData);
            this.newColumn2 = res.columnData;
            // 排序列字段转化格式
            let items = res.columnData.map((item) => {
                return { label: item.dataField, value: item.caption };
            });
            this.setState({
                sortList: items,
            });
            this.forceUpdate();
        }
        if (res) {
            this.colOrders = res.devTableListType;
        }
    }
    // 接口调用
    async getDevListData_popRow(dbName, tname, data_id, fields, where, order, queryMeta, top) {
        let devTableList = [];
        // const columnDas: any = [];
        devTableList = await getDevTableData(dbName, tname, data_id, fields, where, order, queryMeta, top);
        // if (devTableList && devTableList?.length !== 0) {
        //   // 表格表头，从接口动态取值，给表头添加类型
        //   for (let i = 0; i < Object.keys(devTableList?.[0])?.length; i++) {
        //     columnDas.push({
        //       dataField: Object.keys(devTableList[0])[i],
        //       caption: Object.keys(devTableList[0])[i],
        //       fixed: false,
        //       width: "150px",
        //     });
        //   }
        // } else {
        //   return false;
        // }
        // columnDas[0].fixed = true; // 冻结主键第一列
        // this.colDatas = columnDas;
        return { devTableList };
    }
    // 接口调用-针对添加数据类型
    async getDevListData_dataTYpe(dbName, tname, data_id, fields, where, order, queryMeta, top) {
        let devTableListType = [];
        devTableListType = await getDevTableData(dbName, tname, data_id, fields, where, order, true, 0);
        // if (devTableListType && devTableListType?.length !== 0) {
        //   devTableListType.map((item) => {
        //     this.colDatas.map((its) => {
        //       if (its.dataField === item.FieldName) {
        //         its.FieldType = item.FieldType;
        //       }
        //       // return item;
        //     });
        //     return item;
        //   });
        // } else {
        //   return false;
        // }
        let columnData = [];
        if (devTableListType.map) {
            devTableListType.map((item) => {
                columnData.push({
                    dataField: item.FieldName,
                    caption: item.FieldCaption,
                    fixed: false,
                    minWidth: "160px",
                    // width: "180px",
                    // maxWidth: "300px",
                    FieldType: item.FieldType,
                });
                return item;
            });
        }
        else {
            devTableListType = [];
        }
        // console.log("888--columnData", columnData);
        if (columnData && columnData[0]) {
            columnData[0].fixed = true; // 冻结主键第一列
        }
        // console.log("888--devTableListType", devTableListType);
        this.forceUpdate();
        return { devTableListType, columnData };
    }
    /**
     * 初始化参数值
     */
    async doInitParams() {
        await this.updateValParam1(consts.ThisYear); //更新年度
        this.newFilterArrs = []; //筛选条件
        this.props.getConditions(""); //筛选条件
        //不存在公司的,先要清除对应关系
        this.state.saveArr.forEach((item) => (item.sourceMap = ""));
        this.createCpasHeader(true); // 自动获取原始cpas表的数据
        let updateValues = this.getInitParams();
        this.setState(updateValues); //初始化这些值界面参数值
    }
    async componentDidUpdate(prevProps, prevState, snapshot) {
        //console.error("existsRowFormula=" + this.props.existsRowFormula);
        //如果是界面显示时执行
        if (this.props.isShowForm) {
            this.props.setIsShowForm(false); //设置为false
            //没有公式
            if (!this.props.existsRowFormula) {
                await this.doInitParams(); //初始化参数值
                await this.AccountTabsClick(consts.WpTabKey); //激活底稿结构化数据页
            }
            else {
                //有公式
                let cpasHeader = this.createCpasHeader(true); // 自动获取原始cpas表的数据
                this.newProps = this.props; //关系回显需要
                //关系回显,这个方法中会调用  this.getDiGaoOption(); // 底稿结构化数据 - 底稿名称
                if (!this.newColumn2) {
                    await this.getDiGaoOption(); // 底稿结构化数据 - 底稿名称
                }
                await this.getReviewCpasMap(cpasHeader); //关系回显,这个方法中会调用
            }
        }
    }
    async componentDidMount() {
        this.tabName = consts.ReportTabKey;
        this.EnterpriseBaseData(); // 企业基础数据-取数源
        this.getDiGaoOption(); // 底稿结构化数据 - 底稿名称
        //本年 传参到定义公式
        await this.updateValParam1(consts.ThisYear);
        /*  this.props.getYearVal(consts.ThisYear);
         this.setState({
           valParam1: (await getYears(consts.ThisYear)) + "",
         }); */
        /*const currentYeardata =  getYears(consts.ThisYear);
        currentYeardata.then((result) => {
          this.props.getYearVal(consts.ThisYear);
          this.setState({
            valParam1: result.toString(),
          });
        });   */
    }
    /**
     * 更新年度
     * @param yearTag
     */
    async updateValParam1(yearTag) {
        this.props.getYearVal(yearTag);
        this.setState({
            valParam1: (await getYears(yearTag)) + "",
        });
    }
    /**
     * 返回公式数据
     * @returns DrcData
     */
    getDrDataResult() {
        return {
            activeTab: this.state.activeKeys,
            // dbName: state.dbName,  // 为了模板，去掉，6.21 去掉dbname,前端不再传
            // dataList: state.rowSrc2.value, // 取数源 表名 "fa.getList" this.state.dataList ComDataSoureSelect
            dataId: this.state.yearInp,
            fields: [],
            //where: this.state.conditonStr,
            order: this.getOrderStr(),
            top: this.topParam,
            displayReportItem: this.state.selectedValue,
            displayFilters: this.newFilterArrs, ///显示用到的条件, 计算
        };
    }
    render() {
        return (_jsxs(_Fragment, { children: [_jsx("div", { className: "box_bg", children: _jsx("div", { className: "box_flex_col2 mb-24 ", children: this.state.cpasHeader.map((item, index, arr) => {
                            return index === 0 ||
                                index === this.state.cpasHeader.length - 1 ? ("") : (_jsx("div", { onClick: (e) => this.ckRowData(e, index, item), children: _jsxs("div", { className: "box_flex_row cur" +
                                        (this.state.activeIndex3 === index ? " bd_active" : ""), children: [_jsx("div", { className: "diamond", children: createCellPos(index) }), _jsxs("div", { className: "flex_col small_bg", children: [_jsx("div", { className: "f1", children: item.label }), _jsx("div", { children: item.dataListMap ? (_jsxs("span", { children: [_jsx("span", { children: item.dataListMap }), _jsx("span", { title: "\u53D6\u6D88\u5BF9\u5E94", style: { cursor: "pointer" }, onClick: (e) => this.cancelRelation(e, index, item), children: _jsx(CpasIcon, { style: { marginLeft: 10 }, type: "icon-close", color: "red" }) })] })) : (_jsx("span", { style: { color: "red" }, children: "\u5C1A\u672A\u5BF9\u5E94" })) })] })] }) }, index));
                        }) }) }), _jsx("div", { className: "con", children: _jsxs(AntTabs, { tabBarStyle: { background: "#FFF" }, activeKey: this.state.activeKeys, 
                        // onChange={this.AccountTabsClick}
                        onChange: async (activeKey) => {
                            if (this.state.saveArr.length > 0) {
                                Modal.confirm({
                                    content: "切换数据源时,对应关系将被清空,确认要继续吗?",
                                    onOk: async () => {
                                        await this.doInitParams(); //初始化参数值
                                        await this.AccountTabsClick(activeKey);
                                    },
                                    okText: "确认",
                                    cancelText: "取消",
                                });
                            }
                            else {
                                await this.doInitParams(); //初始化参数值
                                await this.AccountTabsClick(activeKey);
                            }
                            //事件结束
                        }, children: [_jsx(AntTabs.Panel, { tab: consts.ReportTabKey, style: { marginTop: "5px" }, children: _jsxs("div", { children: [_jsxs("div", { className: "flexCon mb-10 f12", children: [_jsxs("div", { className: "flex-start", children: [_jsx("div", { className: "mr-8 nowrap", children: "\u53D6\u6570\u6E90:" }), _jsx("div", { className: "mr-24", id: "self_sty", children: _jsx(Select, { defaultValue: this.state.dataSource1, value: this.state.dataSource1, style: { width: 180 }, options: this.state.getComDataSoureSelect, onChange: this.selDataSource1 }) }), _jsx("div", { className: "mr-8 nowrap", children: "\u5E74\u5EA6:" }), _jsx("div", { className: "custom_curYear", children: _jsx(SelectBox, { width: 95, dataSource: consts.YearTagList, value: this.state.yearInp, onValueChanged: (val) => {
                                                                    this.setState({ yearInp: val.value });
                                                                    this.selYear1(val);
                                                                } }) })] }), _jsxs("div", { className: "flex-start", children: [_jsx("div", { className: "mr-8 nowrap", children: "\u9879\u76EE\u540D\u79F0:" }), _jsx("div", { children: _jsx(Input, { style: { height: "30px" }, ref: this.inpRef, size: "small", onPressEnter: this.changeInp1, placeholder: " ", suffix: _jsx(SearchOutlined, { onClick: this.changeInp1 }) }) }), _jsx("div", { className: "icon_refresh", onClick: () => this.refresh1(this.state.yearInp), children: _jsx(CpasIcon, { type: "icon-yuefenzhongzhi" }) })] })] }), _jsx("div", { className: "h200", children: _jsxs(DevGrid.RangeTap, { ref: this.reportGridRef, dataSource: this.newListData1, defaultColumns: this.newColumn1, columns: this.newColumn1, showBorders: true, showRowLines: true, onCellDblClick: this.devTableDbck, columnMinWidth: 120, columnAutoWidth: true, noDataText: "\u65E0\u6570\u636E", rtlEnabled: false, children: [_jsx(Sorting, { mode: "none" }), _jsx(Scrolling, { mode: "infinite" }), _jsx(LoadPanel, { enabled: false })] }) })] }) }, consts.ReportTabKey), _jsx(AntTabs.Panel, { tab: consts.WpTabKey, style: { marginTop: "5px" }, children: _jsxs("div", { children: [_jsxs("div", { className: " mb-10 f12", children: [_jsxs("div", { style: { overflow: "auto", width: "100%" }, className: "flexCon", children: [_jsxs("div", { className: "flex-start", children: [_jsx("div", { className: "mr-8 nowrap", children: "\u5E95\u7A3F\u540D\u79F0:" }), _jsx("div", { className: "mr-8 custom_sel", id: "self_sty", children: _jsx(SelectBox, { placeholder: "\u9009\u62E9\u5E95\u7A3F\u540D\u79F0", noDataText: "\u65E0\u6570\u636E", searchEnabled: true, displayExpr: "label", valueExpr: "value", dataSource: this.state.getDiGaoSourceSelect, defaultValue: this.state.selectedValue, value: this.state.selectedValue, onItemClick: async (e) => {
                                                                            //如果有对应关系
                                                                            if (this.state.saveArr.length > 0) {
                                                                                Modal.confirm({
                                                                                    content: "切换数据源时,对应关系将被清空,确认要继续吗?",
                                                                                    onOk: async () => {
                                                                                        await this.doInitParams(); //初始化参数值
                                                                                        await this.DigaoItem(e.itemData.value);
                                                                                    },
                                                                                    okText: "确认",
                                                                                    cancelText: "取消",
                                                                                });
                                                                            }
                                                                            else {
                                                                                await this.doInitParams(); //初始化参数值
                                                                                await this.DigaoItem(e.itemData.value);
                                                                            }
                                                                            //结束
                                                                        }, dropDownOptions: { width: "300px" } }) }), _jsx("div", { className: "mr-8 nowrap", children: "\u53D6\u6570\u6E90:" }), _jsx("div", { className: "mr-8 custom_sel", id: "self_sty", children: _jsx(Select, { defaultValue: this.state.dataSource2, value: this.state.dataSource2, style: { width: 160 }, options: this.state.getNumberSourceSelect, 
                                                                        //onChange={this.selDataSource2}
                                                                        onChange: async (val, item) => {
                                                                            //如果有对应关系
                                                                            if (this.state.saveArr.length > 0) {
                                                                                Modal.confirm({
                                                                                    content: "切换数据源时,对应关系将被清空,确认要继续吗?",
                                                                                    onOk: async () => {
                                                                                        await this.doInitParams(); //初始化参数值
                                                                                        this.selDataSource2(val, item);
                                                                                    },
                                                                                    okText: "确认",
                                                                                    cancelText: "取消",
                                                                                });
                                                                            }
                                                                            else {
                                                                                await this.doInitParams(); //初始化参数值
                                                                                this.selDataSource2(val, item);
                                                                            }
                                                                            //结束
                                                                        } }) }), _jsx("div", { className: "mr-8 nowrap", children: "\u5E74\u5EA6:" }), _jsx("div", { className: "custom_sel custom_curYear", children: _jsx(SelectBox, { width: 95, dataSource: consts.YearTagList, value: this.state.yearInp, onValueChanged: (val) => {
                                                                            this.setState({ yearInp: val.value });
                                                                            this.selYear2(val);
                                                                        } }) }), _jsxs("div", { ref: this.excludeRef2, className: "flex-start ml-24 cur", onClick: this.filterItem, children: [_jsx(CpasIcon, { className: "icon-size16", sz: "lg", type: "icon-filter" }), _jsx("div", { className: "nowrap", children: "\u7B5B\u9009" }), _jsx("div", { className: "icon-size16 icon-small" })] }), _jsxs("div", { ref: this.excludeRef, className: "flex-start ml-24 cur", onClick: this.isOrders, children: [_jsx(CpasIcon, { className: "icon-size16", sz: "lg", type: "icon-zimudaoxu" }), _jsx("div", { className: "nowrap", children: "\u6392\u5E8F" }), _jsx("div", { className: "icon-size16 icon-small mr-16" })] })] }), _jsxs("div", { className: "flex-start", children: [_jsx("div", { className: "mr-8 nowrap", children: "\u9879\u76EE\u540D\u79F0:" }), _jsx("div", { children: _jsx(Input, { style: { height: "30px", width: "110px" }, ref: this.inpRef2, size: "small", onPressEnter: this.changeInp2, placeholder: " ", suffix: _jsx(SearchOutlined, { onClick: this.changeInp2 }) }) }), _jsx("div", { className: "icon_refresh", onClick: () => this.refresh2(this.state.yearInp), children: _jsx(CpasIcon, { type: "icon-yuefenzhongzhi" }) })] })] }), this.state.isFilter ? _jsx("div", { className: "overlay" }) : null, _jsx("div", { ref: this.filterRef, className: "box_flow", style: { display: `${this.state.isFilter ? "" : "none"}` }, children: _jsx(Card, { title: "\u7B5B\u9009", size: "small", style: {
                                                            border: "1px solid #d8d8d8",
                                                            height: "400px",
                                                            width: "600px",
                                                            // overflowY: "auto",
                                                        }, actions: [
                                                            //确定和取消按钮
                                                            _jsxs("div", { style: { textAlign: "center" }, children: [_jsx(Button, { onClick: this.filterCancel, className: "mr-16", children: "\u53D6\u6D88" }), _jsx(Button, { onClick: this.filterComfirm, type: "primary", children: "\u786E\u5B9A" })] }),
                                                        ], children: _jsxs("div", { style: { height: "335px", overflowY: "auto" }, children: [this.state.components.map((item) => {
                                                                    // console.log("888--item", item);
                                                                    return _jsx("div", { children: item.content }, item.id);
                                                                }), _jsxs("div", { onClick: this.addRow, style: {
                                                                        border: "0px solid #000",
                                                                        cursor: "pointer",
                                                                        width: 60,
                                                                    }, children: [_jsx(CpasIcon, { className: "icon-size32 cur", type: "icon-add-circle" }), "\u589E\u52A0"] })] }) }) }), this.state.isOrder ? _jsx("div", { className: "overlay" }) : null, this.state.isOrder && (_jsx("div", { className: "box_flow", style: { display: `${this.state.isOrder ? "" : "none"}` }, 
                                                    //id="slef_sort"
                                                    ref: this.sortRef, children: _jsx(Card, { title: "\u6392\u5E8F", style: { height: 300, width: 500 }, children: _jsxs("div", { className: "sort_col", children: [_jsxs("div", { className: "sort_row", style: { marginBottom: 20, textAlign: "left" }, children: [_jsx("div", { className: "mr-8 nowrap", children: "\u6570\u636E\u9650\u5236:" }), _jsx("div", { className: "mr-8 custom_sel", id: "self_sty", children: _jsx(Select, { defaultValue: this.state.chgItem, value: this.state.chgItem, style: { width: 142 }, options: this.state.orderOpts, onChange: this.changeItem, showSearch: true }) }), _jsx("div", { className: "mr-8 custom_sel", children: _jsx(Input, { ref: this.inpOrderRef, style: { height: "30px", width: "50px" }, size: "small", onChange: this.changeVal, placeholder: " ", type: "number", min: "0", value: this.state.text2 }) })] }), _jsxs("div", { className: "sort_row", children: [_jsx("div", { className: "mr-8 nowrap", children: "\u8BF7\u9009\u62E9\u5217:" }), _jsx("div", { className: "mr-8 custom_sel", id: "self_sty", children: _jsx(Select, { defaultValue: this.state.sortVal, value: this.state.sortVal, style: { width: 200 }, options: this.state.sortList, onChange: this.getSortVal }) }), _jsx("div", { children: _jsx(Radio.Group, { onChange: this.singleSort2, name: "question1", value: this.state.value1, children: _jsxs("div", { className: "flex-start", children: [_jsx(Radio, { value: "asc", children: _jsxs("div", { className: "sort_row", children: [_jsx(CpasIcon, { className: "icon-size16", type: "icon-zimudaoxu" }), _jsx("div", { children: "\u5347\u5E8F" })] }) }), _jsx(Radio, { value: "desc", children: _jsxs("div", { className: "sort_row", children: [_jsx(CpasIcon, { className: "icon-size16", type: "icon-zimushunxu" }), _jsx("div", { children: "\u964D\u5E8F" })] }) })] }) }) })] }), _jsxs("div", { style: { marginTop: "40px", textAlign: "center" }, children: [_jsx(Button, { onClick: this.clearSort, className: "mr-16", children: "\u6E05\u7A7A" }), _jsx(Button, { className: "mr-16", onClick: () => this.setState({ isOrder: false }), children: "\u53D6\u6D88" }), _jsx(Button, { onClick: this.setConfirmSort, type: "primary", className: "mr-16", children: "\u786E\u5B9A" })] })] }) }) }))] }), _jsx("div", { className: "h200 source-row-data-dev", children: _jsxs(DevGrid.RangeTap, { ref: this.devGridRef2, height: 200, dataSource: this.newListData2, defaultColumns: this.newColumn2, columns: this.newColumn2, 
                                                // dataSource={this.state.digaoList}
                                                // defaultColumns={this.state.digaoColumn}
                                                showBorders: true, showRowLines: true, showColumnLines: true, rowAlternationEnabled: false, onCellDblClick: this.devTableDbck, columnMinWidth: 120, columnAutoWidth: true, noDataText: "\u65E0\u6570\u636E", children: [_jsx(Sorting, { mode: "none" }), _jsx(Scrolling, { mode: "infinite" }), _jsx(LoadPanel, { enabled: false })] }) })] }) }, consts.WpTabKey)] }) })] }));
    }
}
